$(function(){
    $("#type").change(function(){
        var type = $(this).val();
        fieldset(type);
    })
})

function fieldset(type){
    var fieldStr="";
    fieldStr="<table class='fieldset'>";
    switch(type){
        case "text":
            fieldStr+="<tr><th>表单长度</th><td><input type='text' name='fieldset[width]' value='420'/> px</td></tr>";
            fieldStr+="<tr><th>是否为密码</th><td><input type='radio' name='fieldset[ispassword]' value='1'/>是&nbsp;&nbsp;<input type='radio' name='fieldset[ispassword]' value='0' checked='checked'/>否&nbsp;&nbsp;</td></tr>";
            fieldStr+="<tr><th>默认值</th><td><input type='text' name='fieldset[value]' style='width:280px;'/></td></tr>";
            fieldStr+="<tr><th>表字段类型</th><td>\n\
<input type='radio' name='fieldset[fieldtype]' value='char'/> char&nbsp;&nbsp;&nbsp;\n\
<input type='radio' name='fieldset[fieldtype]' value='varchar' checked='checked'/> varchar&nbsp;&nbsp;&nbsp;\n\
                        </td></tr>";
            fieldStr+="<tr><th>字段长度</th><td><input type='text' name='fieldset[fieldsize]' value='100' style='width:280px;'/></td></tr>";
            fieldStr+="<tr><th>css类名</th><td><input type='text' name='fieldset[css]' style='width:120px'/></td></tr>";
            break;
            
        case "textarea":
            fieldStr+="<tr><th>宽度</th><td><input type='text' name='fieldset[width]' value='500'/> px</td></tr>";
            fieldStr+="<tr><th>高度</th><td><input type='text' name='fieldset[height]' value='60'/> px</td></tr>";
            fieldStr+="<tr><th>默认值</th><td><textarea name='fieldset[value]' style='width:400px;height:60px;'></textarea></td></tr>";
            fieldStr+="<tr><th>表字段类型</th><td>\n\
<input type='radio' name='fieldset[fieldtype]' value='text'/> text&nbsp;&nbsp;&nbsp;\n\
<input type='radio' name='fieldset[fieldtype]' value='mediumtext' checked='checked'/> mediumtext&nbsp;&nbsp;&nbsp;\n\
                        </td></tr>";
            fieldStr+="<tr><th>css类名</th><td><input type='text' name='fieldset[css]' style='width:120px'/></td></tr>";
            break;
            
        case "editor":
            fieldStr+="<tr><th>编辑器高度</th><td><input type='text' name='fieldset[height]' value='300'/>px</td></tr>";
            fieldStr+="<tr><th>允许最大字数</th><td><input type='text' name='fieldset[max]' value='99999'/></td></tr>";
            fieldStr+="<tr><th>编辑器风格</th><td><input type='radio' name='fieldset[style]' value='1'/> 完整工具条&nbsp;&nbsp;&nbsp;<input type='radio' name='fieldset[style]' value='2' checked='checked'/>精简版</td></tr>";
            fieldStr+="<tr><th>css类名</th><td><input type='text' name='fieldset[css]' style='width:120px'/></td></tr>";
            break;
        case "upload":
            fieldStr+="<tr><th>允许上传文件大小</th><td><input type='text' name='fieldset[size]' value='2'/> MB</td></tr>";
            fieldStr+="<tr><th>允许上传文件类型</th><td><input type='text' name='fieldset[type]' value='jpg,jpeg,png,gif,bmp,txt'/><span class='desc'>留空为允许上传所有类型</span></td></tr>";
            fieldStr+="<tr><th>允许上传文件数量</th><td><input type='text' name='fieldset[limig]' value='8'/> 个</td></tr>";
            fieldStr+="<tr><th>上传按钮文本</th><td><input type='text' name='fieldset[text]' value='文件上传'/></td></tr>";
            fieldStr+="<tr><th>上传按钮文本</th><td><input type='text' name='fieldset[text]' value='文件上传'/></td></tr>";
            fieldStr+="<tr><th>预览图宽度</th><td><input type='text' name='fieldset[width]' value='150'/></td></tr>";
            fieldStr+="<tr><th>预览图高度</th><td><input type='text' name='fieldset[height]' value='150'/></td></tr>";
            fieldStr+="<tr><th>生成图像大小</th><td><input type='text' name='fieldset[height]'/><span class='desc'>如果设置值 为：200,200,300,300，则生成2张图片，第1张图为200*200第2张图为300*300</span></td></tr>";
            fieldStr+="<tr><th>css类名</th><td><input type='text' name='fieldset[css]' style='width:120px'/></td></tr>";
            break;
        case "int":
            fieldStr+="<tr><th>默认值</th><td><input type='text' name='fieldset[value]' value='0'/></td></tr>";
            fieldStr+="<tr><th>表字段类型</th><td><input type='radio' name='fieldset[style]' value='tinyint'/> tinyint&nbsp;&nbsp;&nbsp;\n\
                    <input type='radio' name='fieldset[fieldtype]' value='smallint'/> smallint&nbsp;&nbsp;&nbsp;\n\
<input type='radio' name='fieldset[fieldtype]' value='int' checked='checked'/> int&nbsp;&nbsp;&nbsp;\n\
                        </td></tr>";
            fieldStr+="<tr><th>css类名</th><td><input type='text' name='fieldset[css]' style='width:120px'/></td></tr>";
            break;   
        default://radio checkbox
            fieldStr+="<tr><th>选择列表</th><td><textarea  name='fieldset[list]' style='width:380px;height:100px;'></textarea><span class='desc'>1|男,2|女 说明:1,2为value值 男,女为提示文本</span></td></tr>";
            fieldStr+="<tr><th>默认值</th><td><input type='text' name='fieldset[value]' style='width:280px;'/></td></tr>";
            fieldStr+="<tr><th>表字段类型</th><td>\n\
<input type='radio' name='fieldset[fieldtype]' value='tinyint' checked='checked'/> tinyint&nbsp;&nbsp;&nbsp;\n\
<input type='radio' name='fieldset[fieldtype]' value='smallint'/> smallint&nbsp;&nbsp;&nbsp;\n\
<input type='radio' name='fieldset[fieldtype]' value='int'/> int&nbsp;&nbsp;&nbsp;\n\
                        </td></tr>";
            fieldStr+="<tr><th>css类名</th><td><input type='text' name='fieldset[css]' style='width:120px'/></td></tr>";
            break;
    }
    fieldStr+="</table>";
    $("#fieldset").empty().html(fieldStr);
}